package com.giibpt.model.entities;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

@Entity
@GenericGenerator(
		name = "subArea",
		strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
		parameters = {
				@Parameter(name="sequence_name", value="sub_area_sequence"),
				@Parameter(name="initial_value", value="1"),
				@Parameter(name="increment_size", value="1")
		}
)
public class SubArea {
	Long idSubArea;
	String nombre;
	Area area;
	
	@Id
	@GeneratedValue(generator="subArea")
	public Long getIdSubArea() {
		return idSubArea;
	}
	public String getNombre() {
		return nombre;
	}
	@ManyToOne(optional=false, fetch=FetchType.EAGER)
	public Area getArea() {
		return area;
	}
	public void setIdSubArea(Long idSubArea) {
		this.idSubArea = idSubArea;
	}
	public void setNombre(String nombre) {
		this.nombre = nombre;
	}
	public void setArea(Area area) {
		this.area = area;
	}

	@Override
	public String toString() {
	
		return area.nombre + " -  " + nombre;
	}
	
}
